﻿using BridgePattern.Sample;
using System;
using System.Configuration;
using System.Reflection;

namespace BridgePattern
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Hello BridgePattern!");

            {
                RefinedAbstraction refined = new RefinedAbstraction();
                refined.Operation();
            }

            {
                Console.WriteLine("应用案例：");
                // 读取App.config 配置文件
                string imageType = ConfigurationManager.AppSettings["image"];
                string osType = ConfigurationManager.AppSettings["os"];

                // 反射生成对象
                AbstractImage image = (AbstractImage)Assembly.Load("BridgePattern").CreateInstance(imageType);
                IImageImp imp = (IImageImp)Assembly.Load("BridgePattern").CreateInstance(osType);

                image.SetImageImp(imp);
                image.ParseFile("中国地图");
            }

            Console.ReadKey();

        }
    }
}
